import { Component, OnInit } from '@angular/core';
import { HttpCustomService } from 'src/app/services/http-custom.service';
import { ApiConfigService } from 'src/app/services/api-config.service';

@Component({
  selector: 'app-http-demo',
  templateUrl: './http-demo.component.html',
  styleUrls: ['./http-demo.component.scss']
})
export class HttpDemoComponent implements OnInit {
  items:any = []
  constructor(private http:HttpCustomService) { }
  ngOnInit() {
    this.getListData(ApiConfigService.contractApi,{});
  }

  getListData(url, body) {
    return this.http.get(url, body).then(data => {
      console.log(data['success'])
      if (data['success'] === true) {
        for (const item of data.data) {
          let tempitem = {
            projectName:item["projectName"],
            projectNo:item["projectNo"],
            contractName:item["contractName"],
            contractNo:item["contractNo"],
            contractType:item["contractType"],
          }
          this.items.push(tempitem);
        }
      } else {
        //请求失败
        console.log("请求失败")
      }
    }).catch(err => {
      console.log(err)
      return err
    })
  }
}
